# -*- coding: utf-8 -*-
"""
@Time    : 2025/3/4 20:09 
@Author  : ZhangShenao 
@File    : 1.通过通义百炼平台调用DeepSeek.py 
@Desc    : 通过通义百炼平台调用DeepSeek
"""

import os

import dotenv
from openai import OpenAI

# 加载环境变量
dotenv.load_dotenv()

# 创建通义百炼客户端,兼容OpenAI协议
client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
)

completion = client.chat.completions.create(
    model="deepseek-r1",  # 指定DeepSeek-R1模型
    messages=[
        {'role': 'user', 'content': '9.9和9.11谁大'}
    ]
)

# 通过reasoning_content字段打印思考过程
print("思考过程：")
print(completion.choices[0].message.reasoning_content)

# 通过content字段打印最终答案
print("最终答案：")
print(completion.choices[0].message.content)
